﻿using System;
using System.IO;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;

namespace ERP.UI.Controls.WPFControls
{
    public partial class Login
    {
        public Login()
        {
            this.InitializeComponent();

            // Insert code required on object creation below this point.
        }

        #region Members

        public string Username
        {
            get { return tbUsername.Text; }
        }
        public string Password
        {
            get { return tbPassword.Password; }
        }

        public bool ShowFailureText
        {
            set
            {
                if ((bool)value)
                    lblFailureMessage.Visibility = Visibility.Visible;
                else
                    lblFailureMessage.Visibility = Visibility.Hidden;
            }
        }
        #endregion

        #region Designer Properties

        [System.ComponentModel.Browsable(true)]
        [System.ComponentModel.Localizable(true)]
        [System.ComponentModel.Category("Common Properties")]
        [System.ComponentModel.Bindable(true)]
        [System.ComponentModel.DisplayName("UsernameLabelText")]
        public string UsernameLabelText
        {
            get { return lblUsername.Content.ToString(); }
            set { lblUsername.Content = value; }
        }

        [System.ComponentModel.Browsable(true)]
        [System.ComponentModel.Localizable(true)]
        [System.ComponentModel.Category("Common Properties")]
        [System.ComponentModel.Bindable(true)]
        [System.ComponentModel.DisplayName("PasswordLabelText")]
        public string PasswordLabelText
        {
            get { return lblPassword.Content.ToString(); }
            set { lblPassword.Content = value; }
        }

        [System.ComponentModel.Browsable(true)]
        [System.ComponentModel.Localizable(true)]
        [System.ComponentModel.Category("Common Properties")]
        [System.ComponentModel.Bindable(true)]
        [System.ComponentModel.DisplayName("FailureText")]
        public string FailureText
        {
            get { return lblFailureMessage.Content.ToString(); }
            set { lblFailureMessage.Content = value; }
        }

        [System.ComponentModel.Browsable(true)]
        [System.ComponentModel.Localizable(true)]
        [System.ComponentModel.Category("Common Properties")]
        [System.ComponentModel.Bindable(true)]
        [System.ComponentModel.DisplayName("BorderVisibility")]
        public Visibility BorderVisibility
        {
            get { return brdrControlBorder.Visibility; }
            set { brdrControlBorder.Visibility = value; }
        }

        [System.ComponentModel.Browsable(true)]
        [System.ComponentModel.Localizable(true)]
        [System.ComponentModel.Category("Common Properties")]
        [System.ComponentModel.Bindable(true)]
        [System.ComponentModel.DisplayName("LoginButtonText")]
        public string LoginButtonText
        {
            get { return btnLogin.Content.ToString(); }
            set { btnLogin.Content = value; }
        }

        [System.ComponentModel.Browsable(true)]
        [System.ComponentModel.Localizable(true)]
        [System.ComponentModel.Category("Common Properties")]
        [System.ComponentModel.Bindable(true)]
        [System.ComponentModel.DisplayName("CancelButtonText")]
        public string CancelButtonText
        {
            get { return btnCancel.Content.ToString(); }
            set { btnCancel.Content = value; }
        }

        #endregion

        #region Events

        public static readonly RoutedEvent LoginButtonClickEvent = EventManager.RegisterRoutedEvent(
           "LoginButtonClick", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(Login));
        public static readonly RoutedEvent CancelButtonClickEvent = EventManager.RegisterRoutedEvent(
           "CancelButtonClick", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(Login));

        public event RoutedEventHandler LoginButtonClick
        {
            add { AddHandler(LoginButtonClickEvent, value); }
            remove { RemoveHandler(LoginButtonClickEvent, value); }
        }
        public event RoutedEventHandler CancelButtonClick
        {
            add { AddHandler(CancelButtonClickEvent, value); }
            remove { RemoveHandler(CancelButtonClickEvent, value); }
        }

        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            RaiseEvent(new RoutedEventArgs(LoginButtonClickEvent));
        }
        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            RaiseEvent(new RoutedEventArgs(CancelButtonClickEvent));
        }
        #endregion
    }
}